package com.itrip.common;

import com.alibaba.fastjson.JSONObject;
import com.itrip.entity.ItripUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * Token验证
 * Created by hanlu on 2017/5/7.
 */
@Slf4j
@Component
public class ValidationToken {
    //引入redis操作模板
    @Autowired
    RedisTemplate<String,Object> redisTemplate;

    public ItripUser getCurrentUser(String tokenString){
        //根据token从redis中获取用户信息
			/*
			 test token:
			 key : token:1qaz2wsx
			 value : {"id":"100078","userCode":"myusercode","userPassword":"78ujsdlkfjoiiewe98r3ejrf","userType":"1","flatID":"10008989"}

			*/
        ItripUser itripUser = null;
        if(null == tokenString || "".equals(tokenString)){
            return null;
        }
        //TODO 通过token使用redis来获取用户的数据

        return itripUser;
    }

}
